package com.etone.smartAudit.controller;

import com.etone.smartAudit.annotation.LoginAdmin;
import com.etone.smartAudit.apiIntercept.Result;
import com.etone.smartAudit.domain.Admin;
import com.etone.smartAudit.domain.IapDataModelRemark;
import com.etone.smartAudit.service.IapDataModelNavService;
import com.etone.smartAudit.service.IapDataModelRemarkService;
import com.etone.smartAudit.vo.iapDataModelNav.IapDataModelNavCountVO;
import com.etone.smartAudit.vo.iapDataModelNav.IapDataModelNavRemarkVO;
import com.etone.smartAudit.vo.iapDataModelNav.IapDataModelNavVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author ：张任豪
 * @date ：2022/2/21 9:45
 * @description：元数据导航
 */
@RestController
@AllArgsConstructor
@Api(tags = "元数据导航", value = "IapDataModelNavController")
public class IapDataModelNavController {

    private IapDataModelNavService iapDataModelNavService;

    private IapDataModelRemarkService iapDataModelRemarkService;

    @ApiOperation(value = "元数据导航列表《完》")
    @GetMapping("IapDataModelNav/list")
    public List<IapDataModelNavVO> list(
            @ApiParam("关键字查询") @RequestParam(required = false) String keyword,
            @ApiParam("交集或者并集(0：交集，1：并集)") @RequestParam(required = false,defaultValue = "1") Integer queryType,
            @ApiParam("敏感性") @RequestParam(required = false) List<Integer> senLevel,
            @ApiParam("数量维护纬度类型") @RequestParam(required = false) List<Integer> dataAssertIds,
            @ApiParam("数量质量纬度") @RequestParam(required = false) List<Integer> dataMassIds,
            @ApiParam("使用方纬度") @RequestParam(required = false) List<Integer> dimensionIds,
            @ApiParam("自动化纬度") @RequestParam(required = false) List<Integer> autoTagIds
    ) {
        return iapDataModelNavService.list(keyword,senLevel,dataAssertIds,dataMassIds,dimensionIds,autoTagIds,queryType);
    }

    @ApiOperation(value = "元数据导航分类统计《完》")
    @GetMapping("IapDataModelNav/countType")
    public List<IapDataModelNavCountVO> countType() {
        return iapDataModelNavService.countType(null);
    }

    @ApiOperation(value = "元数据导航备注《查询》")
    @GetMapping("IapDataModelNav/remark/{id}")
    public List<IapDataModelNavRemarkVO> remarkList(
            @ApiParam("元数据Id") @PathVariable Integer id,
            @ApiIgnore @LoginAdmin Admin admin
    ) {
        return iapDataModelRemarkService.list(id,admin);
    }


    @ApiOperation(value = "元数据导航备注《新增》")
    @PostMapping("IapDataModelNav/remark/{id}")
    public Result addRemark(
            @ApiParam("元数据Id") @PathVariable Integer id,
            @ApiParam("备注") @RequestParam String remark,
            @ApiIgnore @LoginAdmin Admin admin
    ) {
        return iapDataModelRemarkService.addOrUpdateRemark(id,null,remark,admin);
    }

    @ApiOperation(value = "元数据导航备注《编辑》")
    @PutMapping("IapDataModelNav/remark/{id}")
    public Result updateRemark(
            @ApiParam("元数据备注Id") @PathVariable Integer id,
            @ApiParam("备注") @RequestParam String remark,
            @ApiIgnore @LoginAdmin Admin admin
    ) {
        return iapDataModelRemarkService.addOrUpdateRemark(null,id,remark,admin);
    }

    @ApiOperation(value = "元数据导航备注《删除》")
    @DeleteMapping("IapDataModelNav/remark/{id}")
    public Result deleteRemark(
            @ApiParam("元数据备注Id") @PathVariable Integer id,
            @ApiIgnore @LoginAdmin Admin admin
    ) {
        return iapDataModelRemarkService.deleteRemark(id,admin);
    }

    @ApiOperation(value = "分类数据处理接口")
    @GetMapping("IapDataModelNav/test")
    public Result testNav() {
        return iapDataModelNavService.testNav();
    }


}
